﻿@using System.Collections.Generic
@using System.Drawing
@using System.Linq
@using MrCMS.Entities.Documents.Media
@using MrCMS.Helpers
@using MrCMS.Media
@using MrCMS.Paging
@using MrCMS.Web.Areas.Admin.ACL
@using MrCMS.Website
@model MrCMS.Web.Areas.Admin.Models.MediaCategorySearchModel
@{
    Html.IncludeScript("~/Areas/Admin/Content/Scripts/mrcms/media-uploader.js");
    Html.IncludeScript("~/Areas/Admin/Content/Scripts/mrcms/media-category.js");
    Html.IncludeScript("~/Areas/Admin/Content/Scripts/mrcms/media.js");
    var category = ViewData["category"] as MediaCategory;
    var sortByOptions = ViewData["sort-by-options"] as List<SelectListItem> ?? new List<SelectListItem>();
    bool canAccessMediaToolsCut = CurrentRequestData.CurrentUser.CanAccess<MediaToolsACL>(MediaToolsACL.Cut);
    bool canAccessMediaToolsDelete = CurrentRequestData.CurrentUser.CanAccess<MediaToolsACL>(MediaToolsACL.Delete);
}

<div class="margin-bottom-20">
    @{ Html.RenderAction("Upload", "MediaCategory", new { category }); }
    <div class="clearfix"></div>
</div>

@if (category != null)
{
    <ol class="breadcrumb">
        <li><a href="@Url.Action("Index", "MediaCategory")">@Resource("Admin Media", "Media")</a></li>
        @foreach (var folder in category.BreadCrumbs.Reverse())
        {
            <li><a href="@Url.Action("Show", "MediaCategory", new{Id = folder.Id})">@folder.Name</a></li>
        }
    </ol>
}

@using (Html.BeginForm(FormMethod.Get, new { }))
{
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                @Html.LabelFor(model => model.SearchText)
                @Html.TextBoxFor(model => model.SearchText, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                @Html.LabelFor(model => model.SortBy)
                @Html.DropDownListFor(model => model.SortBy, sortByOptions, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-sm-2">
            <div class="form-group">
                <label class="hidden-xs">&nbsp;</label>
                <button type="submit" class="btn btn-primary form-control">@Resource("Search")</button>
            </div>
        </div>
    </div>
}

@if (canAccessMediaToolsCut || canAccessMediaToolsDelete)
{
    <span class="btn-group margin-bottom-20" id="file-tools">
        @{
    if (canAccessMediaToolsCut)
    {
        <button id="cut-files" class="btn btn-default" disabled>@Resource("Cut")</button>
    }
    <button id="paste-files" class="btn btn-default" disabled>@Resource("Paste")</button>
    if (canAccessMediaToolsDelete)
    {
        <button id="delete-files" class="btn btn-default" disabled>@Resource("Delete")</button>
    }
    <button id="clear-files" class="btn btn-default">@Resource("Clear")</button>
        }
    </span>
}
<div class="clearfix"></div>
@{Html.RenderAction("Directory","MediaCategory",Model);}
